package com.wlyuan.open.infrastructure.converter;

import com.wlyuan.core.domain.MappingIds;
import com.wlyuan.core.marker.MappingStatus;
import com.wlyuan.core.marker.MappingValue;
import com.wlyuan.open.dao.entity.OpenClientDO;
import com.wlyuan.open.domain.client.OpenClient;
import com.wlyuan.open.domain.client.utils.MappingOpenClient;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author yuanzheng
 */
public class OpenClientConverter {
    @Mapper(uses = {
            MappingIds.class,
            MappingValue.class,
            MappingStatus.class,
            MappingOpenClient.class
    })
    public interface Converter {
        OpenClient convert(OpenClientDO source);

        List<OpenClient> convert(List<OpenClientDO> source);

        @InheritInverseConfiguration
        OpenClientDO convert(OpenClient source);
    }

    private static final Converter CONVERTER = Mappers.getMapper(Converter.class);

    public static OpenClientDO convert(OpenClient source) {
        return CONVERTER.convert(source);
    }

    public static OpenClient convert(OpenClientDO source) {
        return CONVERTER.convert(source);
    }

    public static List<OpenClient> convert(List<OpenClientDO> source) {
        return CONVERTER.convert(source);
    }
}
